import { ref } from 'vue';

const loadingata = ref({
  requestUrl: '', //当前请求的url
  responseRes: '', //响应结果
  url: '', //需要loading的请求url
  controlLoading: false, //控制显示loading动画的布尔值
});

const getControl = (requstUrl, responseRes, url) => {
  if (url == requstUrl) {
    if (responseRes == url) {
      loadingata.value.controlLoading = false;
    } else {
      loadingata.value.controlLoading = true;
    }
  }
};

const LoadingControl = () => {
  getControl(loadingata.value.requestUrl, loadingata.value.responseRes, loadingata.value.url);
};
export const HttpLoadingControl = () => {
  return { loadingata, LoadingControl };
};
